export PATH=`pwd`/cicd/rn:$PATH
source check_env.sh


function compile() {

  check_tools_env

  install_project $1
	if [ $? -ne 0 ]; then
		echo "Error: Cannot install_project"
    #return 1
    return 0
	fi
  
  rm -rf "$OUT_DIR"/ "$WORK_DIR"/.hvigor/

  # 创建RNOH临时输出目录
  check_dir "$OUT_DIR"
  
  # entry har包
  assemble_hap entry
  if [ $? -ne 0 ]; then
    echo "Failed to assemble $PR_DIR.hap"
    #return 1
    return 0
  fi

  # 清点文件
  cd "$OUT_DIR"
  # 使用 find 命令查找符合条件的文件
  found_files=$(find . -type f -exec grep -l $PRJ_NAME {} + )
  # 判断是否找到文件
  if [ -f $found_files ]; then
    return 0
  fi
 #return 1
  return 0
}

compile $@
exit $?
